// 解构赋值
<template>
  <div>
    <prism language="javascript">
      //对象的解构赋值
      var [a, b] = ["yuan", "lei"];
      console.log(a); 

      //如果在对象中没有赋值，就会出现undefind
      var { c, d } = { c: "yuan", d: "lei" };
      console.log(c);

      //变量交换
      [a, b] = [b, a]; 
      console.log(a);

      let { length: chang } = "yaunlei";
      console.log(chang);
    </prism>
    <v-btn
      round
      color="success"
      @click="run"
    >
      RUN
    </v-btn>
  </div>
</template>

<script>
import Prism from "vue-prism-component";
export default {
  components: {
    Prism
  },
  methods: {
    run() {
      //对象的解构赋值
      var [a, b] = ["yuan", "lei"];
      console.log(a); 

      //如果在对象中没有赋值，就会出现undefind
      var { c, d } = { c: "yuan", d: "lei" };
      console.log(c);

      //变量交换
      [a, b] = [b, a]; 
      console.log(a);

      let { length: chang } = "yaunlei";
      console.log(chang);
    }
  }
};
</script>